﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Bas;

namespace nERP.Model.Bas
{
    /// <summary>
    /// 计量单位
    /// </summary>
	[Table("ComputationUnit")]
    [SoftKey(nameof(ComputationUnit.UnitCode))]
    [Display(Name = "_Model.ComputationUnit")]
    public class ComputationUnit : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._ComputationUnit._UnitCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("单位编码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string UnitCode { get; set; }
        [Display(Name = "_Model._ComputationUnit._UnitName")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("单位名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string UnitName { get; set; }
        [Display(Name = "_Model._Goods._GoodsUnit")]
        [InverseProperty("GoodsUnit")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Bas.Goods.GoodsUnitId))]
        public List<Goods> Goods_GoodsUnit { get; set; }
        [Display(Name = "_Model._ComputationUnit._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
